<html>
<head><meta charset="utf-8"><title>ConstArg lowering · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html">ConstArg lowering</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223965112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223965112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223965112">(Jan 25 2021 at 21:46)</a>:</h4>
<p>Regarding <a href="https://github.com/rust-analyzer/rust-analyzer/issues/7432">https://github.com/rust-analyzer/rust-analyzer/issues/7432</a> which just popped up, I wonder how would we go about lowering these const expressions in type param position? I remember having that question in my head when I added them to the HIR. Technically those expressions are bodies right? Which means we would have to lower them lazily but that seems to go against the fact that types are lowered eagerly right?</p>



<a name="223966109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223966109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223966109">(Jan 25 2021 at 21:54)</a>:</h4>
<p>good question. I do think we could lower them lazily; the type would only contain the ID of the expression (body) anyway</p>



<a name="223966334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223966334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223966334">(Jan 25 2021 at 21:56)</a>:</h4>
<p>we do need a place to put them, give them IDs and find them again though, which isn't so easy since they can appear everywhere</p>



<a name="223968858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223968858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223968858">(Jan 25 2021 at 22:08)</a>:</h4>
<p>those bodies could even contain local functions and modules <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="223969388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223969388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223969388">(Jan 25 2021 at 22:11)</a>:</h4>
<p>Oh no, that sounds just lovely <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="223969578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223969578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223969578">(Jan 25 2021 at 22:12)</a>:</h4>
<p>So this might be relevant to the DefMap stuff as well then? Since <span class="user-mention silent" data-user-id="211727">Jonas Schievink</span> is working on that part to support local items it might be good to keep that in mind</p>



<a name="223971741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223971741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223971741">(Jan 25 2021 at 22:26)</a>:</h4>
<p>hmm, yeah, tricky</p>



<a name="223971830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223971830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223971830">(Jan 25 2021 at 22:27)</a>:</h4>
<p>Currently we can compute a <code>Body</code> for any <code>DefWithBodyId</code>, which is just functions, statics and consts</p>



<a name="223971861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223971861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223971861">(Jan 25 2021 at 22:27)</a>:</h4>
<p>We'd have to extend that to be nestable inside types</p>



<a name="223971976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/223971976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#223971976">(Jan 25 2021 at 22:28)</a>:</h4>
<p>Possibly by an <code>AstId</code>-like scheme but for these expression roots?</p>



<a name="224006089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ConstArg%20lowering/near/224006089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ConstArg.20lowering.html#224006089">(Jan 26 2021 at 07:52)</a>:</h4>
<p>urgh, if only salsa had an <code>db.allocate_id()</code> method...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>